package georah.map.tools
{

	import flash.events.EventDispatcher;

	import georah.map.Map;

	/**
	 *
	 * @author yuanm
	 */
	public class MapTool extends EventDispatcher
	{
		public function MapTool()
		{
			addEventListener(MapToolEvent.ENABLE, this_enableHandler);
			addEventListener(MapToolEvent.DISABLE, this_disableHandler);
		}

		private var _enabled:Boolean=false;

		private var _map:Map=null;

		public final function disable():void
		{
			if (!enabled)
			{
				return;
			}
			dispatchEvent(new MapToolEvent(MapToolEvent.DISABLE));
			_map=null;
			_enabled=false;
		}

		public final function enable(map_:Map):void
		{
			if (enabled)
			{
				return;
			}
			_map=map_;
			dispatchEvent(new MapToolEvent(MapToolEvent.ENABLE));
			_enabled=true;
		}

		public final function get enabled():Boolean
		{
			return _enabled;
		}

		virtual public function get keyboardLocked():Boolean
		{
			return false;
		}

		virtual public function get mouseLocked():Boolean
		{
			return false;
		}

		protected final function get map():Map
		{
			return _map;
		}

		virtual protected function this_disableHandler(event:MapToolEvent):void
		{
			//
		}

		virtual protected function this_enableHandler(event:MapToolEvent):void
		{
			//
		}

	}
}
